package com.groupbuying.sysconfig.controller.notify;


import com.groupbuying.sysconfig.service.notify.NotifyTemplate;
import com.groupbuying.sysconfig.utils.apiresult.ApiResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Description 支付宝生活号模版消息
 * @Auther Davidbieber
 * @Email davidbieber@163.com
 * @Date 2019/10/17 4:58 PM
 */

@Api("微信、支付宝小程序/公众号/生活号模版消息")
@RestController
@RequestMapping("/notify")
public class NotifyController {

    @Autowired
    private NotifyTemplate notifyTemplate;

    /**
     * @api {POST} notify/weChatPublicApp 微信公众号模版消息
     * @apiExample
     * author davidbieber
     * tar api内部调用
     * date 2019/10/31 12:20 下午
     * @apiGroup service-sysConfig
     * @apiVersion 1.0.0
     * @apiHeader {String} Authorization 用户授权token
     * @apiParam {String} openId 用户微信openId
     * @apiParam {String} templateId 微信公众号模板ID
     * @apiParam {String} indicate 消息工具类唯一标识
     * @apiParam {Object} data 微信公众号消息体
     * @apiSuccess ApiResult
     */

    @PostMapping("/weChatPublicApp")
    public ApiResult doWechatAppTemplateSend(@RequestParam  Map<String,Object> params){
        return notifyTemplate.doWechatAppTemplateNotify(params);
    }

    /**
     * @api {POST} notify/weChatMiniApp 微信小程序模板消息
     * @apiExample
     * author davidbieber
     * tar api内部调用
     * date 2019/10/31 12:19 下午
     * @apiGroup service-sysConfig
     * @apiVersion 1.0.0
     * @apiHeader {String} Authorization 用户授权token
     * @apiParam {String} openId 用户微信openId
     * @apiParam {String} formId 用户微信formId
     * @apiParam {String} templateId 用户微信模版ID
     * @apiParam {String} indicate 消息工具类唯一标识
     * @apiParam {Object} data 用户微信消息体
     * @apiSuccess {Object} ApiResult
     */

    @PostMapping("/weChatMiniApp")
    public ApiResult doWechatMiniTemplateSend(@RequestParam  Map<String,Object> params){
        return notifyTemplate.doWechatMiniTemplateNotify(params);
    }

    /**
     * @api {POST} notify/aliPublicApp 支付宝生活号模板消息
     * @apiExample
     * author davidbieber
     * tar api内部调用
     * date 2019/10/31 12:13 下午
     * @apiGroup service-sysConfig
     * @apiVersion 1.0.0
     * @apiHeader {String} Authorization 用户授权token
     * @apiParam {String} toUserId 支付宝用户ID
     * @apiParam {String} headColor 支付宝消息体头部颜色
     * @apiParam {String} actionName 支付宝消息体头部名称
     * @apiParam {String} templateId 支付宝模板ID
     * @apiParam {String} indicate 消息工具类唯一标识
     * @apiParam {Object} data 支付宝消息体
     * @apiSuccess {Object} ApiResult 返回ApiResult
     */
    @PostMapping("/aliPublicApp")
    public ApiResult doAlipayAppTemplateSend(@RequestParam  Map<String,Object> params){
        return notifyTemplate.doAlipayAppTemplateNotify(params);
    }

    /**
     * @api {POST} notify/aliMiniApp 支付宝小程序模板消息
     * @apiExample
     * author davidbieber
     * tar api内部调用
     * date 2019/10/31 12:17 下午
     * @apiGroup service-sysConfig
     * @apiVersion 1.0.0
     * @apiHeader {String} Authorization 用户授权token
     * @apiParam {String} toUser 支付宝小程序用户ID
     * @apiParam {String} formId 支付宝小程序表单ID
     * @apiParam {String} templateId 支付宝模板ID
     * @apiParam {String} indicate 消息工具类唯一标识
     * @apiParam {Object} data 支付宝小程序消息体
     * @apiSuccess {Object} ApiResult 支付宝小程序消息返回值
     */
    @PostMapping("/aliMiniApp")
    public ApiResult doAlipayMiniTemplateSend(@RequestParam  Map<String,Object> params){
        return notifyTemplate.doAlipayMiniTemplateNotify(params);
    }
}
